import psutil


def get_ip_addresses():
    try:
        net_if_addrs = psutil.net_if_addrs()
        for interface_name, interface_addresses in net_if_addrs.items():
            print(f"\n网卡名称: {interface_name}")
            for address in interface_addresses:
                if address.family == 2:
                    print(f"IPv4地址: {address.address}")
                    print(f"子网掩码: {address.netmask}")
                elif address.family == 10:
                    print(f"IPv6地址: {address.address}")

    except Exception as e:
        print(e)



